﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ucb.Workshop.Business.Util;
using System.Windows.Forms;
using Ucb.Workshop.Business;
using Ucb.Workshop.Dal;
using System.Data.SqlClient;

namespace Ucb.Workshop.Tests
{
    /// <summary>
    /// Summary description for UtilControlTest
    /// </summary>
    [TestClass]
    public class UtilControlTest
    {
        public UtilControlTest()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion
        //--------------------------------------eliminar  proveedor---------------------
        [TestMethod]
        public void validareliminar()
        {
            DBManager conexion = new DBManager();

            ProviderManager proveedor = new ProviderManager();
            proveedor.Cod_proveedor = 10;
            proveedor.Ciudad = "cocha";
            proveedor.Banco = "economico";
            proveedor.Direccion = "av.heroinas";
            proveedor.Empresa = "cobol";
            proveedor.Fax = 123;
            proveedor.Telefono = 45454;
            proveedor.NumeroCuenta = "1232";

            proveedor.Registrar();
            proveedor.Eliminar();
            string consulta = "SELECT * FROM proveedor WHERE cod_proveedor=10";
            SqlDataReader valores = conexion.ExeConsulta(consulta);
            Assert.IsFalse(valores.HasRows);
        }

        [TestMethod]
        public void ValidarTextBoxTest()
        {
            TextBox texto = new TextBox();
            texto.Text = "hola";
            Assert.IsTrue(UtilControl.ValidarTextBox(texto));
           
        }


        
     
        [TestMethod]
        public void ValidarMasketTextBoxTest()
        {
            MaskedTextBox mTextBox = new MaskedTextBox();
            mTextBox.Text = "1234";
            Assert.IsTrue(UtilControl.ValidarMasketTextBox(mTextBox));
           
        }

        [TestMethod]
        public void ValidarTextBoxDecimalTest()
        {
            TextBox texto = new TextBox();
            texto.Text = "1.3";
            Assert.IsTrue(UtilControl.ValidarTextBoxDecimal(texto));

            texto.Text = "hola";
           Assert.IsFalse(UtilControl.ValidarTextBoxDecimal(texto));
        }

       

        [TestMethod]
        public void ValidarTextBoxEnteroTest()
        {
            TextBox texto = new TextBox();
            texto.Text = "100";
            Assert.IsTrue(UtilControl.ValidarTextBoxEntero(texto));

            texto.Text = "1.3";
            Assert.IsFalse(UtilControl.ValidarTextBoxEntero(texto));
        }

        //[TestMethod]
        //public void EscribirDecimalTest()
        //{
        //    TextBox texto = new TextBox();
        //    texto.Text = "1.3";
        //    TextBox texto2 = new TextBox();
        //    texto2.Text = "1.3";
        //    Assert.AreEqual(

          
        //}




        /// <summary>
        ///A test for ValidarTelefono
        ///</summary>
        [TestMethod()]
        public void ValidarTelefonoTest()
        {
            string numero = "76543210"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateTelephone(numero);
            Assert.AreEqual(expected, actual);

        }
        /// <summary>
        ///A test for ValidarTelefono
        ///</summary>
        [TestMethod()]
        public void ValidarTelefonoNegativeTest()
        {
            string numero = "abcdefg"; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateTelephone(numero);
            Assert.AreEqual(expected, actual);
           
        }

        /// <summary>
        ///A test for ValidarTexto
        ///</summary>
        [TestMethod()]
        public void ValidarTextoTest()
        {
            string texto = "abcdefg"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateText(texto);
            Assert.AreEqual(expected, actual);
            
        }
        /// <summary>
        ///A test for ValidarTexto
        ///</summary>
        [TestMethod()]
        public void ValidarTextoNegativeTest()
        {
            string texto = "123123"; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateText(texto);
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        ///A test for ValidarCorreo
        ///</summary>
        [TestMethod()]
        public void ValidarCorreoTest()
        {
            string texto = "abc_cde@gmail.com"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateEmail(texto);
            Assert.AreEqual(expected, actual);
           
        }
        /// <summary>
        ///A test for ValidarCorreo
        ///</summary>
        [TestMethod()]
        public void ValidarCorreoNegativeTest()
        {
            string texto = " asbsab@gmail.com"; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateEmail(texto);
            Assert.AreEqual(expected, actual);
            string texto2 = "asasg  @gamil.com";
            bool expected2= false;
            bool actual2;
            actual2 = UtilControl.ValidateEmail(texto2);
            Assert.AreEqual(expected2, actual2);

        }

        /// <summary>
        ///A test for ValidarDireccion
        ///</summary>
        [TestMethod()]
        public void ValidarDireccionTest()
        {
            string texto = "America oeste#123"; // TODO: Initialize to an appropriate value
            bool expected = true; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateAddress(texto);
            Assert.AreEqual(expected, actual);
            
        }
        /// <summary>
        ///A test for ValidarDireccion
        ///</summary>
        [TestMethod()]
        public void ValidarDireccionNegativeTest()
        {
            string texto = " America  oeste#123"; // TODO: Initialize to an appropriate value
            bool expected = false; // TODO: Initialize to an appropriate value
            bool actual;
            actual = UtilControl.ValidateAddress(texto);
            Assert.AreEqual(expected, actual);

        }
    }
}
